//
//  SNamespace.m
//  SimulacraDB
//
//  Created by Andre Cohen on 9/4/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "SNamespace.h"
#import "DataSourceBTree.h"
#import "RecordFactory.h"


@implementation SNamespace

- (id)init {
	[super init];
	
	Record *prototype = [RecordFactory createNamespaceRecord:nil];
	source = [[[DataSourceBTree alloc] initWithDataSource:@"namespace" recordPrototype:prototype] autorelease];
	
	[source addIndexWithName:@"name" block:0];
	
	return self;
}

- (Record *)createNamespace:(NSString *)name {
	Record *ns = [RecordFactory createNamespaceRecord:name];
	[source insertRecord:ns];
	return ns;
}

- (NSArray *)getNamespace:(NSString *)name {
	return [source getRecord:[RecordFactory createNamespaceRecord:name]
				  usingIndex:@"name"];
}

@end
